package com.ruoyi.riv.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.DataScope;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.riv.domain.RiverTactics;
import com.ruoyi.riv.service.IRiverTacticsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 一河一档一策Controller
 * 
 * @author ruoyi
 * @date 2024-10-23
 */
@RestController
@RequestMapping("/riv/tactics")
public class RiverTacticsController extends BaseController
{
    @Autowired
    private IRiverTacticsService riverTacticsService;

    /**
     * 查询一河一档一策列表
     */
    @PreAuthorize("@ss.hasPermi('riv:tactics:list')")
    @GetMapping("/list")

    public TableDataInfo list(RiverTactics riverTactics)
    {
        startPage();
        List<RiverTactics> list = riverTacticsService.selectRiverTacticsList(riverTactics);
        return getDataTable(list);
    }

    /**
     * 导出一河一档一策列表
     */
    @PreAuthorize("@ss.hasPermi('riv:tactics:export')")
    @Log(title = "一河一档一策", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RiverTactics riverTactics)
    {
        List<RiverTactics> list = riverTacticsService.selectRiverTacticsList(riverTactics);
        ExcelUtil<RiverTactics> util = new ExcelUtil<RiverTactics>(RiverTactics.class);
        util.exportExcel(response, list, "一河一档一策数据");
    }

    /**
     * 获取一河一档一策详细信息
     */
    @PreAuthorize("@ss.hasPermi('riv:tactics:query')")
    @GetMapping(value = "/{tacticsId}")
    public AjaxResult getInfo(@PathVariable("tacticsId") String tacticsId)
    {
        return success(riverTacticsService.selectRiverTacticsByTacticsId(tacticsId));
    }

    /**
     * 新增一河一档一策
     */
    @PreAuthorize("@ss.hasPermi('riv:tactics:add')")
    @Log(title = "一河一档一策", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RiverTactics riverTactics)
    {
        return toAjax(riverTacticsService.insertRiverTactics(riverTactics));
    }

    /**
     * 修改一河一档一策
     */
    @PreAuthorize("@ss.hasPermi('riv:tactics:edit')")
    @Log(title = "一河一档一策", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RiverTactics riverTactics)
    {
        return toAjax(riverTacticsService.updateRiverTactics(riverTactics));
    }

    /**
     * 删除一河一档一策
     */
    @PreAuthorize("@ss.hasPermi('riv:tactics:remove')")
    @Log(title = "一河一档一策", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tacticsIds}")
    public AjaxResult remove(@PathVariable String[] tacticsIds)
    {
        return toAjax(riverTacticsService.deleteRiverTacticsByTacticsIds(tacticsIds));
    }
}
